/*
 * SPDX-License-Identifier: Apache-2.0
 */
package org.hyperledger.fabric.samples.fabFileModel;

import java.util.Date;
import java.util.Objects;

import org.hyperledger.fabric.contract.annotation.DataType;
import org.hyperledger.fabric.contract.annotation.Property;

import com.owlike.genson.annotation.JsonProperty;

@DataType()
public final class Log {

    @Property()
    private final String date;

    @Property()
    private final String userId;

    @Property()
    private final String operation;

    @Property()
    private final String result;

	public String getDate() {
		return date;
	}

	public String getUserId() {
		return userId;
	}

	public String getOperation() {
		return operation;
	}

	public String getResult() {
		return result;
	}
	
	public Log(@JsonProperty("date") String date, @JsonProperty("userId") String userId, @JsonProperty("operation") String operation, @JsonProperty("result") String result) {
		super();
		this.date = date;
		this.userId = userId;
		this.operation = operation;
		this.result = result;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((operation == null) ? 0 : operation.hashCode());
		result = prime * result + ((this.result == null) ? 0 : this.result.hashCode());
		result = prime * result + ((userId == null) ? 0 : userId.hashCode());
		return result;
	}
	
	@Override
	public String toString() {
		return "Log [date=" + date + ", userId=" + userId + ", operation=" + operation + ", result=" + result + "]";
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Log other = (Log) obj;
		if (operation == null) {
			if (other.operation != null)
				return false;
		} else if (!operation.equals(other.operation))
			return false;
		if (result == null) {
			if (other.result != null)
				return false;
		} else if (!result.equals(other.result))
			return false;
		if (userId == null) {
			if (other.userId != null)
				return false;
		} else if (!userId.equals(other.userId))
			return false;
		return true;
	}
}
